//
//  OrderHistoryInfoTableViewCell.m
//  OrderAssistant
//
//  Created by chendong on 2020/8/26.
//  Copyright © 2020 chendong. All rights reserved.
//

#import "OrderHistoryInfoTableViewCell.h"
@interface OrderHistoryInfoTableViewCell()
@property(nonatomic,strong)UILabel *ddbhL;
@property(nonatomic,strong)UILabel *xdrqL;
@property(nonatomic,strong)UILabel *zdrL;
@property(nonatomic,strong)UILabel *xdbmL;
@property(nonatomic,strong)UILabel *cdxdbmL;
@property(nonatomic,strong)UILabel *zdrLP;
@property(nonatomic,strong)UILabel *xdbmLu;
@end
@implementation OrderHistoryInfoTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor = [UIColor clearColor];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        UIView *bgV = [[UIView alloc]initWithFrame:CGRectMake(10, 0, SCREENWIDTH-20, 100)];
        bgV.backgroundColor = [UIColor whiteColor];
        [self.contentView addSubview:bgV];
        
        UILabel *ddbhL = [[UILabel alloc]initWithFrame:CGRectMake(5, 0, bgV.frame.size.width-10, 35)];
        ddbhL.text = @"大米";
        ddbhL.textColor = [UIColor blackColor];
        ddbhL.font = [UIFont fontWithName:@"Helvetica-Bold" size:16];
        [bgV addSubview:ddbhL];
        self.ddbhL = ddbhL;
        
        UILabel *zdrLP = [[UILabel alloc]initWithFrame:CGRectMake(5, CGRectGetMaxY(ddbhL.frame), bgV.frame.size.width/3, 30)];
        zdrLP.text = @"30.00元";
        zdrLP.font = [UIFont systemFontOfSize:15];
        zdrLP.textColor = [UIColor blackColor];
        [bgV addSubview:zdrLP];
        self.zdrLP = zdrLP;
        
        UILabel *xdrqL = [[UILabel alloc]initWithFrame:CGRectMake(ddbhL.frame.origin.x, CGRectGetMaxY(zdrLP.frame), ddbhL.frame.size.width/4, 35)];
        xdrqL.text = @"00312321";
        xdrqL.textColor = [UIColor blackColor];
        [bgV addSubview:xdrqL];
        self.xdrqL = xdrqL;
        
        UILabel *zdrL = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(xdrqL.frame), CGRectGetMaxY(zdrLP.frame), ddbhL.frame.size.width/4, 35)];
        zdrL.text = @"1*50";
        zdrL.textColor = [UIColor blackColor];
        [bgV addSubview:zdrL];
        self.zdrL = zdrL;
        
        UILabel *xdbmL = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(zdrL.frame), CGRectGetMaxY(zdrLP.frame), ddbhL.frame.size.width/4, 35)];
        xdbmL.text = @"袋";
        xdbmL.textColor = [UIColor blackColor];
        [bgV addSubview:xdbmL];
        self.xdbmL = xdbmL;
        
        UILabel *xdbmLu = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(zdrL.frame), CGRectGetMaxY(ddbhL.frame), ddbhL.frame.size.width-CGRectGetMaxX(self.zdrLP.frame), 30)];
        xdbmLu.font = [UIFont systemFontOfSize:15];
        xdbmLu.text = @"¥30";
        xdbmLu.textColor = [UIColor blackColor];
        xdbmLu.textAlignment = NSTextAlignmentLeft;
        [bgV addSubview:xdbmLu];
        self.xdbmLu = xdbmLu;
        
        UILabel *cdxdbmL = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(xdbmL.frame), CGRectGetMaxY(zdrLP.frame), ddbhL.frame.size.width/4, 35)];
        cdxdbmL.text = @"30";
        cdxdbmL.textColor = [UIColor blackColor];
        [bgV addSubview:cdxdbmL];
        self.cdxdbmL = cdxdbmL;
    }
    return self;
}
-(void)setDic:(NSDictionary *)dic{
    _dic = dic;
    self.ddbhL.text = [NSString stringWithFormat:@"%@",dic[@"MaterialName"]];
    self.xdrqL.text = [NSString stringWithFormat:@"%@",dic[@"MaterialID"]];
    self.zdrL.text = [NSString stringWithFormat:@"%@",dic[@"MaterialGG"]];
    self.xdbmL.text = [NSString stringWithFormat:@"%@",dic[@"MaterialStoreUnit"]];
    self.cdxdbmL.text = [NSString stringWithFormat:@"%@",dic[@"MaterialNum"]];
    self.xdbmLu.text = [NSString stringWithFormat:@"小计：¥%.2f",[[NSString stringWithFormat:@"%@",dic[@"MaterialNum"]] floatValue] * [[NSString stringWithFormat:@"%@",dic[@"MaterialPrice"]] floatValue]];
    if ([[dic allKeys] containsObject:@"MaterialPrice"]) {
        self.zdrLP.text = [NSString stringWithFormat:@"¥%@",dic[@"MaterialPrice"]];
        NSString *str = [NSString stringWithFormat:@"%@",[[NSUserDefaults standardUserDefaults] objectForKey:@"IsShowPrice"]];
        if ([dic[@"MaterialPrice"] isKindOfClass:[NSNull class]] || [str isEqualToString:@"0"]) {
            self.zdrLP.hidden = YES;
            self.xdbmLu.hidden = YES;
        }else{
            self.zdrLP.hidden = NO;
            self.xdbmLu.hidden = NO;
        }
    }else{
        self.zdrLP.hidden = YES;
        self.xdbmLu.hidden = YES;
    }
}
@end
